package adke.models.powerups;

import adke.Util;
import adke.models.Player;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.security.acl.Owner;

public abstract class Powerup
{
    public final static int IMG_DIMENSION = 40;
    
    // plaats op het veld
    private int x, y;
    
    // niet private: moet beschikbaar zijn
    protected Player owner;
    
    private Image graphic;
    
    public Powerup(Player owner)
    {
        this.owner = owner;
        x = -1; y = -1;
    }
    
    public Powerup()
    {
        x = -1; y = -1;
    }
    
    public void setOwner(Player newOwner)
    {
        owner = newOwner;
    }
    
    public Player getOwner()
    {
        return owner;
    }
    
    public String toString()
    {
        return this.getClass().getSimpleName();
    }
    
    public Image getGraphic()
    {
        if (graphic == null) graphic = Util.getEmptyImage();
        return graphic;
    }
    
    public void setLocation(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    
    public int getX()
    {
        return x;
    }
    
    public int getY()
    {
        return y;
    }
    
    public boolean isOnLocation(int lineX, int lineY)
    {
        Rectangle r = getLocation();
        return r.contains(lineX, lineY);
    }
    
    public Rectangle getLocation()
    {
        return new Rectangle(x, y, IMG_DIMENSION, IMG_DIMENSION);
    }
}
